Skip to content

chore: clustering mode is required for pyroscope #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 18, 2025

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Aug 15, 2025

Profiling cannot occur by 2 agents at the same time. Clustering distributed these jobs evenly across agents.

This is to solve this error in production on agents:

server returned HTTP status (500) Could not enable CPU profiling: cpu profiling already in use

Validated locally

Ran without clustering with 4 nodes and 1 coder, I get the error without fail.

err="server returned HTTP status (500) Could not enable CPU profiling: cpu profiling already in use"

Extra

I bet this prometheus error is a similar problem:

subcomponent=rw remote_name=2e33aa url=http://prometheus.coder-observability.svc/api/v1/write count=1871 exemplarCount=0 err="server returned HTTP status 400 Bad Request: out of order sample"

Maybe we should cluster scrape prometheus as well?

Emyrk added 2 commits August 15, 2025 09:51
Profiling cannot occur by 2 agents at the same time. Clustering
distributed these jobs evenly across agents
Prometheus ignores this, as clustering block is not used
@Emyrk Emyrk requested a review from dannykopping as a code owner August 15, 2025 14:56
@@ -210,6 +210,10 @@ pyroscope.scrape "pods" {

scrape_interval = "{{ .Values.global.telemetry.profiling.scrape_interval }}"
scrape_timeout = "{{ .Values.global.telemetry.profiling.scrape_timeout }}"

clustering {
enabled = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we enabling this by default with no means to disable it intentionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set to true. When grafana agents are not running in cluster mode, this block is a no-op:

https://grafana.com/docs/agent/latest/flow/reference/components/pyroscope.scrape/#clustering-block

If Grafana Agent Flow is not running in clustered mode, this block is a no-op.

So you can disable this behavior by doing:

grafana-agent:
  agent:
    clustering:
      enabled: false # <- Now the clustering block in the agent config is a no-op

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess the question is, is there a use case to run agents in cluster mode, but not use cluster mode for the profiling.

As of now, I don't think there is. If we use more clustering features, then maybe we can add more knobs.

@Emyrk Emyrk merged commit 5ec395f into main Aug 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants